package router

import (
	"go-im/src/middlewares"
	"go-im/src/service"

	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

// @apiFolder 用户管理
func Router() *gin.Engine {
	r := gin.Default()
	//添加swagger访问路由
	// http://127.0.0.1:8080/swagger/index.html
	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

	// 用户登录
	// UserController 用户相关接口
	r.POST("/login", service.Login)

	r.POST("/send/code", service.SendCode)

	r.POST("/register", service.Register)

	// auth below
	auth := r.Group("/u", middlewares.AuthCheck())
	auth.GET("/user/detail", service.UserDetail)

	auth.POST("/user/complete", service.UserComplete)

	auth.POST("/room/complete", service.RoomComplete)

	// look for friends
	auth.GET("/user/query", service.UserQuery)

	auth.GET("/websocket/message", service.WebsocketMessage)

	auth.GET("/chat/list", service.ChatList)

	auth.POST("/friend/add", service.FriendAdd)
	// @Summary 删除friend
	auth.DELETE("/friend/delete", service.FriendDelete)

	return r
}
